import { _decorator, Component, Node } from 'cc';
const { ccclass, property } = _decorator;

@ccclass('JJWXR_SceneManager')
export class JJWXR_SceneManager extends Component {

    public levelIndex: number = 0;

    @property({ type: Node })
    public sceneNode: Node[] = [];

    start() {
        // 读取本地数据，获取当前关卡数
        let curLevel = parseInt(localStorage.getItem('currentLevel')) % 6;
        if (curLevel == 0) curLevel = 6;
        let index = curLevel - 1;
        switch (index) {
            case 0:
                this.levelIndex = 0;
                break;
            case 1:
                this.levelIndex = 1;
                break;
            case 2:
                this.levelIndex = 2;
                break;
            case 3:
                this.levelIndex = 3;
                break;
            case 4:
                this.levelIndex = 4;
                break;
            case 5:
                this.levelIndex = 5;
        }
        // let level = JSON.parse(localStorage.getItem('level01'));
        // this.levelIndex = level.level;

        // 加载场景节点
        // this.sceneNode = this.node.children;
        for (let i = 0; i < this.sceneNode.length; i++) {
            if (i == this.levelIndex) {
                this.sceneNode[i].active = true;
            }
            else {
                this.sceneNode[i].active = false;
            }
        }

    }

}